<?php
/**
 * Project: AIGC
 * Author: moufer <moufer@163.com>
 * Date: 2024/7/6 09:33
 */

namespace module\ai\front\table;

use module\ai\library\channel\Factory;
use mof\front\Table;
use mof\utils\DictArray;
use mof\utils\ElementData;

class KeyTable extends Table
{
    protected string $serverBaseUrl  = '/{module}/admin/{table}';
    protected array  $toolbarButtons = ['refresh'];

    protected function columnId(): array
    {
        return [
            "prop"  => 'id',
            "label" => 'ID',
        ];
    }

    protected function columnFlag(): array
    {
        return [
            "prop"    => 'flag',
            "label"   => '平台',
            "search"  => true,
            "type"    => "select",
            "options" => Factory::platformDict('key')->toElementData()->toSelectOptions(),
            "width"   => 110
        ];
    }

    protected function columnConfigTxt(): array
    {
        return [
            "prop"   => 'config_txt',
            "label"  => '密钥信息',
            "width"  => "*"
        ];
    }

    protected function columnRemark(): array
    {
        return [
            "prop"  => 'remark',
            "label" => '备注',
            "width" => "140"
        ];
    }

    protected function columnStatus(): array
    {
        return [
            "prop"    => 'status',
            "label"   => '状态',
            "type"    => "select",
            "search"  => true,
            "options" => ElementData::make(DictArray::make([
                '1'  => '正常',
                '0'  => '禁用',
                '-1' => '失效',
            ]))->toSelectOptions(),
        ];
    }

    protected function columnCreateAt(): array
    {
        return [
            "prop"  => 'create_at',
            "label" => '新建时间',
            "type"  => "datetime"
        ];
    }
}